package core.world;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.util.Vector;

public class WallGroup {
	
	private Vector<Wall> walls = new Vector<Wall>();
	private int[] xPoints, yPoints, dxP, dyP;
	private int numberOfWalls;
	
	public WallGroup(Vector<Point> polygon){
		Point p1, p2;
		numberOfWalls=polygon.size();
		xPoints = new int[numberOfWalls];
		yPoints = new int[numberOfWalls];
		dxP = new int[numberOfWalls];
		dyP = new int[numberOfWalls];
		for(int i = 0; i<numberOfWalls; i++){
			p1=polygon.get(i);
			p2=polygon.get( (i+1)%numberOfWalls );
			Wall newWall = new Wall(p1, p2);
			newWall.setVisible(false);
			walls.add( newWall );
			xPoints[i] = p1.x;
			yPoints[i] = p1.y;
		}
	}
	public Vector<Wall> getWalls(){
		return walls;
	}
	public void paint(Point screenOffset, int zoomDivider, Graphics g){
		g.setColor(Color.black);
		for(int i = 0; i<numberOfWalls; i++){
			dxP[i] = (xPoints[i]-screenOffset.x) / zoomDivider;
			dyP[i] = (yPoints[i]-screenOffset.y) / zoomDivider;
		}
		
		g.fillPolygon(dxP, dyP, numberOfWalls);
	}
}
